home *** CD-ROM | disk | FTP | other *** search
- #define PRECOGNITION_UTILS_BODY
-
- #include "precognition_utils.h"
- #include "minmax.h"
- #ifndef __GNUC__
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/diskfont_protos.h>
- #endif
- #ifdef __GNUC__
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/diskfont.h>
- #endif
- #ifdef __SASC
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/diskfont.h>
- #endif
- #include <stdio.h> /* for debugging printf */
-
- #include "amigamem.h"
- #include <string.h>
-
- /* 1.3 Amiga OS Screen Support */
-
- #define RES_MASK (HIRES+LACE)
- #define LO_RES 0
- #define LO_RES_INTERLACE LACE
- #define HI_RES HIRES
- #define HIRES_INTERLACE HIRES+LACE
-
- tPoint pcg_AspectRatio( USHORT ViewModes )
- {
- tPoint ratio;
- USHORT ScreenRes;
-
- ScreenRes = ( ViewModes & ( RES_MASK ) ); /* Ignore other bits. */
- switch( ScreenRes )
- {
- case LO_RES:
- case HIRES_INTERLACE:
- ratio.x = 1;
- ratio.y = 1;
- break;
-
- case LO_RES_INTERLACE:
- ratio.x = 1;
- ratio.y = 2;
- break;
-
- case HIRES:
- ratio.x = 2;
- ratio.y = 1;
- break;
- }
- return ratio;
- }
-
- /* Chaining Gadget Support */
-
- void ChainGadgets( Gadget *start_of_chain, Gadget *gadget )
- {
- Gadget *g;
-
- for( g = start_of_chain; g->NextGadget != NULL; g = g->NextGadget );
- g->NextGadget = gadget;
- }
-
-
- /* Default Font Support */
-
- TextAttr pcg_Topaz80 =
- { "topaz.font", TOPAZ_EIGHTY, FS_NORMAL, FPF_ROMFONT };
-
- struct TextAttr Helvetica13 = {
- "Helvetica.font",
- 13,
- NULL,
- FPF_DISKFONT
- };
-
- #define FONTHEIGHT 9
- #define FONTWIDTH 8
-
-
- void AlignText( PrecogText *ptext,
- Point size )
- {
- PIXELS width;
- UBYTE flags;
- BYTE Xpad, Ypad;
- struct TextFont *myfont = NULL;
- int TextFontHeight = FONTHEIGHT;
-
- flags = ptext->alignment.Flags;
- Xpad = ptext->alignment.Xpad;
- Ypad = ptext->alignment.Ypad;
-
- if( ptext->ITextFont ) /* non NULL */
- {
- /*
- * Additions by EDB October 21, 1994
- * Get Text Width according to ITextFont
- */
- if( myfont = OpenDiskFont( ptext->ITextFont ) )
- {
- if( ptext->IText )
- {
- width = IntuiTextLength( (struct IntuiText *)ptext );
- ptext->TextLength = width;
- }
- else
- width = 0;
-
- /* Change font height variable to match ITextFont */
- TextFontHeight = ptext->ITextFont->ta_YSize;
-
- CloseFont( myfont );
- }
-
- }
- else
- if( ptext->IText ) /* Default Topaz80 font */
- {
- width = strlen( ptext->IText ) * FONTWIDTH;
- }
- else
- {
- width = 0;
- }
-
- /*--------------- ptext->LeftEdge = ? -------------------*/
- if( flags & tx_XCENTER )
- {
- ptext->LeftEdge = size.x/2 - width/2;
- }
- else if( flags & tx_RIGHT )
- {
- if( flags & tx_OUTSIDE )
- ptext->LeftEdge = size.x + Xpad;
- else
- ptext->LeftEdge = size.x - Xpad - width;
- }
- else /* left */
- {
- if( flags & tx_OUTSIDE )
- ptext->LeftEdge = -Xpad - width;
- else
- ptext->LeftEdge = Xpad;
- }
-
- /*--------------- ptext->TopEdge = ? ---------*/
-
- if( flags & tx_YCENTER )
- {
- ptext->TopEdge = size.y/2 - TextFontHeight/2;
- }
- else if( flags & tx_BOTTOM )
- {
- if( flags & tx_OUTSIDE )
- ptext->TopEdge = size.y + Ypad;
- else
- ptext->TopEdge = size.y - Ypad - TextFontHeight;
- }
- else /* Top */
- {
- if( flags & tx_OUTSIDE )
- ptext->TopEdge = -Ypad - TextFontHeight;
- else
- ptext->TopEdge = Ypad;
- }
-
- }
-
- /*
- * Additions by EDB October 21, 1994
- * Get PrecogText Width according to ITextFont
- */
-
- void pcgTextSize( PrecogText *ptext)
-
- {
- LONG width;
- struct TextFont *myfont = NULL;
- if( ptext->ITextFont ) /* non NULL */
- {
- if( myfont = OpenDiskFont( ptext->ITextFont ) )
- {
- if( ptext->IText )
- width = IntuiTextLength( (struct IntuiText *)ptext );
- else
- width = 0;
- CloseFont( myfont );
- }
- }
- else
- if( ptext->IText ) /* Default Topaz80 font */
- {
- width = strlen( ptext->IText ) * FONTWIDTH;
- }
- else
- {
- width = 0;
- }
- ptext->TextLength = width;
- }
-